<template>
  <div class="glass-table-container">
    <a-table
      v-bind="$attrs"
      :class="['glass-table', { 'glass-table--loading': loading }]"
      :loading="false"
    >
      <template v-for="(_, name) in $slots" #[name]="slotData">
        <slot :name="name" v-bind="slotData || {}"></slot>
      </template>
    </a-table>
    
    <!-- 自定义加载状态 -->
    <div v-if="loading" class="glass-table__loading">
      <div class="loading-content">
        <div class="loading-spinner"></div>
        <span class="loading-text">加载中...</span>
      </div>
    </div>
  </div>
</template>

<script setup lang="ts">
interface Props {
  loading?: boolean
}

withDefaults(defineProps<Props>(), {
  loading: false
})
</script>

<style scoped>
.glass-table-container {
  position: relative;
  background: rgba(30, 42, 58, 0.8);
  backdrop-filter: blur(20px);
  -webkit-backdrop-filter: blur(20px);
  border-radius: 16px;
  border: 1px solid rgba(255, 255, 255, 0.1);
  overflow: auto;
  box-shadow: 0 8px 32px rgba(0, 0, 0, 0.3);
  width: 100%;
}

.glass-table :deep(.ant-table) {
  background: transparent;
  color: rgba(255, 255, 255, 0.9);
  width: 100%;
}

.glass-table :deep(.ant-table-content) {
  overflow-x: auto;
}

.glass-table :deep(.ant-table-thead > tr > th) {
  background: rgba(59, 130, 246, 0.2);
  border-bottom: 1px solid rgba(255, 255, 255, 0.1);
  color: #ffffff;
  font-weight: 600;
  text-shadow: 0 1px 2px rgba(0, 0, 0, 0.3);
  border-radius: 0;
}

.glass-table :deep(.ant-table-thead > tr > th::before) {
  display: none;
}

.glass-table :deep(.ant-table-tbody > tr > td) {
  background: transparent;
  border-bottom: 1px solid rgba(255, 255, 255, 0.05);
  color: rgba(255, 255, 255, 0.9);
}

.glass-table :deep(.ant-table-tbody > tr:hover > td) {
  background: rgba(255, 255, 255, 0.05);
}

.glass-table :deep(.ant-table-tbody > tr:nth-child(even) > td) {
  background: rgba(255, 255, 255, 0.02);
}

.glass-table :deep(.ant-table-tbody > tr:nth-child(even):hover > td) {
  background: rgba(255, 255, 255, 0.07);
}

.glass-table :deep(.ant-table-placeholder) {
  background: transparent;
  color: rgba(255, 255, 255, 0.6);
}

.glass-table :deep(.ant-empty-description) {
  color: rgba(255, 255, 255, 0.6);
}

.glass-table :deep(.ant-pagination) {
  margin: 16px 0 0;
  padding: 16px 24px;
  background: rgba(15, 23, 42, 0.6);
  border-top: 1px solid rgba(255, 255, 255, 0.1);
}

.glass-table :deep(.ant-pagination-item) {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
}

.glass-table :deep(.ant-pagination-item a) {
  color: rgba(255, 255, 255, 0.8);
}

.glass-table :deep(.ant-pagination-item:hover) {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
}

.glass-table :deep(.ant-pagination-item-active) {
  background: rgba(59, 130, 246, 0.8);
  border-color: rgba(59, 130, 246, 0.9);
}

.glass-table :deep(.ant-pagination-item-active a) {
  color: #ffffff;
}

.glass-table :deep(.ant-pagination-prev),
.glass-table :deep(.ant-pagination-next) {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
}

.glass-table :deep(.ant-pagination-prev:hover),
.glass-table :deep(.ant-pagination-next:hover) {
  background: rgba(255, 255, 255, 0.2);
  border-color: rgba(255, 255, 255, 0.3);
}

.glass-table :deep(.ant-pagination-prev .ant-pagination-item-link),
.glass-table :deep(.ant-pagination-next .ant-pagination-item-link) {
  color: rgba(255, 255, 255, 0.8);
  background: transparent;
  border: none;
}

.glass-table :deep(.ant-pagination-disabled) {
  opacity: 0.5;
}

.glass-table :deep(.ant-pagination-options) {
  color: rgba(255, 255, 255, 0.8);
}

.glass-table :deep(.ant-select-selector) {
  background: rgba(255, 255, 255, 0.1);
  border: 1px solid rgba(255, 255, 255, 0.2);
  border-radius: 8px;
  color: rgba(255, 255, 255, 0.9);
}

.glass-table :deep(.ant-select-arrow) {
  color: rgba(255, 255, 255, 0.6);
}

.glass-table__loading {
  position: absolute;
  top: 0;
  left: 0;
  right: 0;
  bottom: 0;
  background: rgba(15, 23, 42, 0.8);
  display: flex;
  align-items: center;
  justify-content: center;
  z-index: 10;
}

.loading-content {
  display: flex;
  flex-direction: column;
  align-items: center;
  gap: 16px;
}

.loading-spinner {
  width: 32px;
  height: 32px;
  border: 3px solid rgba(255, 255, 255, 0.2);
  border-top: 3px solid #60a5fa;
  border-radius: 50%;
  animation: spin 1s linear infinite;
}

@keyframes spin {
  0% { transform: rotate(0deg); }
  100% { transform: rotate(360deg); }
}

.loading-text {
  color: rgba(255, 255, 255, 0.8);
  font-size: 14px;
}

/* 滚动条样式 */
.glass-table :deep(.ant-table-body) {
  scrollbar-width: thin;
  scrollbar-color: rgba(255, 255, 255, 0.3) transparent;
}

.glass-table :deep(.ant-table-body::-webkit-scrollbar) {
  width: 6px;
  height: 6px;
}

.glass-table :deep(.ant-table-body::-webkit-scrollbar-track) {
  background: rgba(255, 255, 255, 0.1);
  border-radius: 3px;
}

.glass-table :deep(.ant-table-body::-webkit-scrollbar-thumb) {
  background: rgba(255, 255, 255, 0.3);
  border-radius: 3px;
}

.glass-table :deep(.ant-table-body::-webkit-scrollbar-thumb:hover) {
  background: rgba(255, 255, 255, 0.5);
}

/* 响应式设计 */
@media (max-width: 768px) {
  .glass-table :deep(.ant-pagination) {
    padding: 12px 16px;
  }
  
  .glass-table :deep(.ant-table-thead > tr > th),
  .glass-table :deep(.ant-table-tbody > tr > td) {
    padding: 8px;
    font-size: 14px;
  }
}
</style>
